﻿using System.Collections.Generic;

using NHibernate;
using NHibernate.Criterion;
using SharpArch.Data.NHibernate;

using Quiziqal.Domain;

namespace Quiziqal.Persistence
{
    public class QuizRepository : Repository<Quiz>, IQuizRepository
    {
        public ICollection<Quiz> FindQuizzesByOwner(User owner)
        {
            ICriteria criteria = Session.CreateCriteria(typeof (Quiz))
                .Add(Expression.Eq("Owner.ID", owner.ID))
                .AddOrder(new Order("Name", true));

            return criteria.List<Quiz>() as List<Quiz>;
        }
    }
}
